package main

import (
	"context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"grpc-learning/proto/user"
	"log"
)

func main() {
	conn, err := grpc.DialContext(context.Background(), "127.0.0.1:8001", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatal("连接失败", err)
	}

	defer conn.Close()

	client := user.NewUserClient(conn)

	resp, err := client.GetUser(context.Background(), &user.GetUserReq{Id: "1"})
	if err != nil {
		log.Fatal("请求失败", err)
	}
	log.Println(resp)
}
